package com.mmy.fta.usercenter.bo;

import com.github.pagehelper.util.StringUtil;
import com.mmy.fta.usercenter.entity.OpenidUserEntity;
import com.mmy.fta.usercenter.repository.OpenidUserMapper;
import com.ymm.common.rpc.YmmResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author qingyu.meng
 * @date 2021年10月19日 7:52 下午
 * @Description
 */
@Component
public class UserBO {
    @Autowired
    OpenidUserMapper openidUserMapper;

    public YmmResult saveOpenId(String openId) {
        if (StringUtil.isEmpty(openId)){
            return YmmResult.failResult(000,"openId为空");
        }
        OpenidUserEntity openidUserEntity = new OpenidUserEntity();
        openidUserEntity.setOpenId(openId);
        int insertResult = openidUserMapper.insertSelective(openidUserEntity);
        if (insertResult != 1){
            return YmmResult.failResult(000,"保存openId失败");
        }
        return YmmResult.succResult();
    }
}
